3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
The QuickDraw 3D shape and set routines are discussed in "Managing Shapes" .
The Q3Shape_GetSet and Q3ShapeSetSet calls are implemented via the element type kQ3ElementTypeSet :
typedef long TQ3ElementType;
#define kQ3ElementTypeNone 0
#define kQ3ElementTypeUnknown 32
#define kQ3ElementTypeSet 33
#define kQ3ElementTypeName 34
#define kQ3ElementTypeURL 35
The expression Q3Shape_GetSet(s,&o) is eqivalent to
Q3Shape_GetElement(s, kQ3ElementTypeSet, &o)
The expression Q3Shape_SetSet(s,o) is eqivalent to
Q3Shape_SetElement(s, kQ3ElementTypeSet, &o)
It is important to note that a Q3Shape_ ... Element ... call does not create a set on a shape and then add the element to it. The data is attached directly to the shape. Therefore, it is possible for an element to exist on a shape without a set existing on it as well.
In your application, if you attach an element to a shape in this way:
set = Q3Set_New();
Q3Set_AddElement(set, ElemType, &data);
Q3Shape_SetSet(shape, set);
You should retrieve it in the same manner:
Q3Shape_GetSet(shape, &set);
if (Q3Set_Contains(set, ElemType) == kQ3True) {
Q3Set_Get(set, ElemType, &data);
}
Similarly, if you attach data to a shape with the call
Q3Shape_AddElement(shape, ElemType, &data);
You should retrieve it in the same manner:
if (Q3Shape_ContainsElement(
set, ElemType) == kQ3True) {
Q3Shape_GetElement(set, ElemType, &data);
}
When attempting to find a particular element on a shape, you should first check with Q3Shape_GetNextElementType or Q3Shape_GetElement . Then you should call
Q3Shape_GetElement(s, kQ3ElementTypeSet, &set)) .
Finally, you should call Q3Shape_GetElement(set, ...) .
In terms of implementation, Q3Shape_SetSet and Q3Shape_GetSet should be used only for sets of information that are shared among multiple shapes. Q3Shape_AddElement , Q3Shape_GetElement , and similar calls should be used only for elements that are unique to a particular shape.
Previous | QD3D Book | Overview | Chapter Contents | Next |